<template>
    <div id="artinfo">
        <div class="bread">
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>咨询详情</el-breadcrumb-item>
                <!-- <el-breadcrumb-item>活动列表</el-breadcrumb-item>
                <el-breadcrumb-item>活动详情</el-breadcrumb-item> -->
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="left">
                <div class="title">{{ artinfo.title }}</div>
                <div class="info">
                    <div class="time">{{ artinfo.addtime }}</div>
                    <div class="from">
                        来源:{{ artinfo.author }}
                    </div>
                    <div class="read">
                        阅读数: {{ artinfo.click }}
                    </div>
                </div>
                <div class="content">
                    <div class="inner">
                        <p v-html="artinfo.content"></p>
                    </div>
                </div>
            </div>
            <div class="right">
                <!-- 1 -->
                <div class="rtitle">
                    <div class="txt">
                        最新咨询
                    </div>
                    <div class="inset">
                        进入资讯频道 >>
                    </div>
                </div>
                <!-- 2 -->
                <div class="list_box">
                    <div class="list_item">
                        <div class="tag">1</div>
                        <div class="list_title">
                            咨询标题咨询标题咨询标题咨询标题咨询标题咨询标题咨询标题咨询标题
                        </div>
                    </div>
                    <div class="list_item">
                        <div class="tag">2</div>
                        <div class="list_title">
                            咨询标题咨询标题咨询标题咨询标题咨询标题咨询标题咨询标题咨询标题
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                artid: "",
                artinfo: {},

            }
        },
        created () {
            let artid = this.$route.params.artid;
            // console.log(artid);
            this.artid = artid
            this.getArt( this.artid )
        },
        methods: {
            // 根据ID获取文章
            async getArt( id ) {
                let params = this.$route.params
                let res = ""
                if (params.type == "index") {
                     res = await this.$axios.post("/port/index/article", { key: this.$key, id})
                } else {
                    res = await this.$axios.post("/port/index/erwenzhang", { key: this.$key, id})
                }
                
                //  console.log(res);
                let art = res.data.data
                art.content = this.artMat(art.content)
                this.artinfo = art
            },
            // 文章内容格式化
            artMat( val ) {
                let str = ""
                let reg = /&lt;/g
                let reg1 = /&gt;/g
                let reg3 = /&quot;/g
                let reg4 = /&amp;quot;/g
                let reg5 = /com/g
                str = val.replace(reg3, '').replace(reg,"<").replace(reg1,">").replace(reg4, "").replace(/mini/g,"www").replace(reg5, "club")
                return str
            },
        },
    }
</script>

<style lang="scss" scoped>
#artinfo {
    width: 100%;
    box-sizing: border-box;
    padding: 20px 0;
    .bread {
        width: 1200px;
        margin: 0 auto;
        // background-color: #fff;
        padding: 20px 0;
    }
    .container {
        width: 1200px;
        margin: 20px auto;
        display: flex;
        justify-content: space-between;
        .left {
            width: 780px;
            padding: 20px 30px;
            background-color: #fff;
            .title {
                width: 100%;
                font-size: 24px;
                // height: 40px;
                // line-height: 40px;
                font-weight: bold;
            }
            .info {
                width: 100%;
                box-sizing: border-box;
                font-size: 12px;
                color: #aaa;
                display: flex;
                height: 40px;
                line-height: 40px;
                align-items: center;
                justify-content: space-between;
            }
            .content {
                width: 100%;
            }
        }
        .right {
            width: 300px;
            background-color: #fff;
            box-sizing: border-box;
            .rtitle {
                width: 100%;
                padding: 20px 10px 20px 20px;
                box-sizing: border-box;
                font-size: 18px;
                display: flex;
                justify-content: space-between;
                border-bottom: 1px solid #f2f2f2;
                
                .txt {
                    width: 100px;
                    border-left: 1px solid red;
                    text-align: center;
                    
                }
                .inset {
                    font-size: 12px;
                    color: #aaa;
                }
            }
            .list_box {
                width: 100%;
                padding: 10px;
                box-sizing: border-box;
                
                .list_item {
                    width: 100%;
                    display: flex;
                    align-items: center;
                    height: 40px;
                    line-height: 40px;
                    .tag {
                        width: 20px;
                        height: 20px;
                        background-color: red;
                        text-align: center;
                        line-height: 20px;
                        color: #fff;
                    }
                    .list_title {
                        width: 250px;
                        margin-left: 10px;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                    }
                }
            }
        }
    }

}
</style>